Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mode selector settings sync with url correctly #1202

Merged
merged 5 commits into from
Apr 30, 2024

Conversation

daniel-heppner-ibigroup
Copy link
Contributor

@daniel-heppner-ibigroup daniel-heppner-ibigroup commented Apr 22, 2024

Description:
The root of this bug is that we replace the URL search with the currentQuery every time a trip plan is sent off for keys that are defined in core-utils query-params file. However, in some cases (it seems like when a request isn't successful), the currentQuery doesn't get updated with new values from the mode selector. This sync issue means that the old value from currentQuery replaces the value in the URL.

I found what I think is the simplest way of fixing this, by ensuring that the currentQuery is directly updated at the same time that URL is updated by the mode selector. However, it looks a bit weird because the setQueryParam function only updates URL search values stored inside queryParamData, while the higher level gets put in currentQuery directly. A bit funky.

PR Checklist:

  • Does the code follow accessibility standards (WCAG 2.1 AA Compliant)?
  • Are all languages supported (Internationalization/Localization)?
  • Are appropriate Typescript types implemented?

@@ -223,6 +225,10 @@ function BatchSettings({
)
const accentColor = tinycolor(baseColor).darken(10)

const _onSettingsUpdate = (params: any) => {
setQueryParam({ queryParamData: params, ...params })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should setQueryParam be used for callback _toggleModeButton too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use it for that! I don't know of any sync bugs affecting that, I think because those keys are not in conflict with the ones defined in query-params.js in core-utils. But I think it wouldn't hurt to use it and would probably make things more resilient. I'll try it out.

Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix. Keep us posted regarding #1202 (comment).

Copy link
Collaborator

@miles-grant-ibigroup miles-grant-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working great!

@@ -81,6 +82,7 @@ function BatchSettings({
modeSettingValues,
onPlanTripClick,
routingQuery,
setQueryParam,
setUrlSearch,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need setUrlSearch? Is it used somewhere else? Should we use something else instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daniel-heppner-ibigroup Yeah you can delete setUrlSearch from this file.

@daniel-heppner-ibigroup daniel-heppner-ibigroup merged commit af8be49 into dev Apr 30, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants